package com.dji.compose_learning.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

class SampleListViewModel : ViewModel() {
    private val _sampleDataList = MutableLiveData(
        listOf(
            "This is first item of this list view.",
            "Can you take me to hospital?",
            "Let's go,it's to swimming.",
            "Today is Sunny,should we go beach?",
            "写英语实在是太累的，我不会啊？",
            "怎样才能坚持每天学习英语呢？",
            "如果我学会了英语可以靠这个技艺赚钱吗？"
        )
    )

    val sampleList: LiveData<List<String>>
        get() = _sampleDataList

    fun removeItem(item: String) {
        _sampleDataList.postValue(_sampleDataList.value?.toMutableList()!! - listOf(item).toSet())
    }

    fun addItem(item: String) {
        _sampleDataList.postValue(_sampleDataList.value?.toMutableList()!! + listOf(item))
    }

}